<html>
<head><meta charset="utf-8"><title>Naming question · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html">Naming question</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="180907235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907235">(Nov 16 2019 at 10:40)</a>:</h4>
<p>We have a <code>Source&lt;T&gt;</code> type which is basically a pair of <code>T</code> and <code>HirFileId</code>, where <code>T</code> is somthing relative to file. </p>
<p>What's the best name for the field which holds <code>T</code>? Currently it's called <code>ast</code>, but that doesn't always makes sense:</p>
<ul>
<li><code>Source&lt;ast::FnDef&gt;</code> -- ast is ast, OK</li>
<li><code>Source&lt;SyntaxNode&gt;</code> -- ast is cst, hmm...</li>
<li><code>Source&lt;TextUnit&gt;</code> -- ast is offset, wat?</li>
</ul>



<a name="180907243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907243">(Nov 16 2019 at 10:41)</a>:</h4>
<p>Maybe <code>of</code>?</p>



<a name="180907308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907308">(Nov 16 2019 at 10:43)</a>:</h4>
<p>Hm,</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">node</span>: <span class="nc">Source</span><span class="o">&lt;</span><span class="n">SyntaxNode</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">parent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">node</span><span class="p">.</span><span class="n">of</span><span class="p">.</span><span class="n">parent</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="180907377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907377">(Nov 16 2019 at 10:45)</a>:</h4>
<p>I was just thinking that <code>this is the Source of T</code> makes some sense. You're right -  as a field to access, it's not very clear.</p>



<a name="180907547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907547">(Nov 16 2019 at 10:51)</a>:</h4>
<p>Otoh,</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="p">(</span><span class="n">node</span>: <span class="nc">Source</span><span class="o">&lt;</span><span class="n">SyntaxNode</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">parent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">node</span><span class="p">.</span><span class="n">it</span><span class="p">.</span><span class="n">parent</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>might actually not look that bad...</p>



<a name="180907990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180907990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180907990">(Nov 16 2019 at 11:05)</a>:</h4>
<p>Ahem, is <code>value</code> too traditional?</p>



<a name="180908035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20question/near/180908035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20question.html#180908035">(Nov 16 2019 at 11:07)</a>:</h4>
<p>I like value!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>